<template>
	<rx-dialog @ok="handleSubmit" @cancel="cancel">
		<rx-layout>
            <template #middle>
				<a-form :model="measureConf">
					<a-row>
						<a-col :span="12">
							<a-form-item :label="screenLangI18n('common.fieldLabel','字段备注')" style="width:85%">
								<a-input v-model:value="measureConf.fieldLabel"></a-input>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item :label="screenLangI18n('common.aggregate','聚合方式')" style="width:85%">
								<a-select v-model:value="measureConf.aggregate" :getPopupContainer="p=>p.parentNode" >
									<a-select-option value="COUNT">{{screenLangI18n('form.count','计数')}}(COUNT)</a-select-option>
									<a-select-option value="COUNTD">{{screenLangI18n('form.deCount','去重计数')}}(COUNTD)</a-select-option>
									<a-select-option value="SUM">{{screenLangI18n('form.sum','求和')}}(SUM)</a-select-option>
									<a-select-option value="AVG">{{screenLangI18n('form.average','均值')}}(AVG)</a-select-option>
									<a-select-option value="MAX">{{screenLangI18n('form.maxValue','最大值')}}(MAX)</a-select-option>
									<a-select-option value="MIN">{{screenLangI18n('form.minValue','最小值')}}(MIN)</a-select-option>
									<a-select-option value="NONE">{{screenLangI18n('form.not','无')}}(NONE)</a-select-option>
								</a-select>
							</a-form-item>
						</a-col>
					</a-row>
					<a-row>
						<a-col :span="12">
							<a-form-item :label="chartLangI18n('common.format','格式化')" style="width:85%">
								<a-select v-model:value="measureConf.formatter" :getPopupContainer="p=>p.parentNode">
									<a-select-option value="notFormat">{{screenLangI18n('common.unformatted','不格式化')}}</a-select-option>
									<a-select-option value="thousands">{{screenLangI18n('common.thousand','千分位')}}</a-select-option>
									<a-select-option value="percentage">{{screenLangI18n('common.percent','百分比')}}</a-select-option>
									<a-select-option value="trillion">{{screenLangI18n('common.digital','数字转千/万/亿')}}</a-select-option>
								</a-select>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item label="小数位" style="width:85%">
								<a-select v-model:value="measureConf.decimal" :getPopupContainer="p=>p.parentNode">
									<a-select-option value="notHandle">{{screenLangI18n('common.decimalsNot','不处理')}}</a-select-option>
									<a-select-option value="roundNumbers">{{screenLangI18n('common.roundNumbers','取整数')}}</a-select-option>
									<a-select-option value="oneDecimals">{{screenLangI18n('common.KeepOnePlace','保留一位小数')}}</a-select-option>
									<a-select-option value="twoDecimals">{{screenLangI18n('common.KeepTwoPlace','保留两位小数')}}</a-select-option>
									<a-select-option value="threeDecimals">{{screenLangI18n('common.KeepThreePlace','保留三位小数')}}</a-select-option>
								</a-select>
							</a-form-item>
						</a-col>
					</a-row>
					<a-row>
						<a-col :span="12">
							<a-form-item :label="screenLangI18n('common.numericPrefix','数值前缀')" style="width:85%">
								<a-input v-model:value="measureConf.prefix" :placeholder="screenLangI18n('common.pleasePrefix','数值前缀')" ></a-input>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item :label="screenLangI18n('common.numericSuffix','数值后缀')" style="width:85%">
								<a-input v-model:value="measureConf.suffix" :placeholder="screenLangI18n('common.pleaseSuffix','数值后缀')"></a-input>
							</a-form-item>
						</a-col>
					</a-row>
					<a-row>
						<a-col :span="12">
							<a-form-item :label="screenLangI18n('common.roundUp','四舍五入')" style="width:85%">
								<a-switch size="small" v-model:checked="measureConf.halfAdjust" />
							</a-form-item>
						</a-col>
					</a-row>
                    <a-row>
                        <a-col :span="24">
                            <a-form-item :label="screenLangI18n('common.sort','排序')">
                                <a-radio-group v-model:value="measureConf.sort">
                                    <a-radio value="default">{{screenLangI18n('common.default','默认')}}</a-radio>
                                    <a-radio value="DESC">{{screenLangI18n('common.desOrder','降序')}}(DESC)</a-radio>
                                    <a-radio value="ASC">{{screenLangI18n('common.ascOrder','升序')}}(ASC)</a-radio>
                                </a-radio-group>
                            </a-form-item>
                        </a-col>
                    </a-row>
				</a-form>
			</template>
		</rx-layout>
	</rx-dialog>
</template>

<script>
import {Util,RxLayout,RxDialog} from "@lowcode/jpaas-base-lib";

export default {
	name: "NumericalMeasurement",
	props:['destroy',"measure"],
	components:{
		RxLayout,
		RxDialog
	},
	data() {
		return {
			measureConf:{
				fieldLabel:"",
				formatter:"notFormat",
				decimal:"notHandle",
				prefix:"",
				suffix:"",
				halfAdjust:false,
				aggregate:"",
			}
		}
	},
	created() {
		this.init();
	},
	methods: {
		screenLangI18n(name,text,key){
			return this.$ti18(name,text,"screenLang",key);
		},
		chartLangI18n(name, text, key) {
			return this.$ti18(name, text, "chartLang", key);
		},
		init(){
			this.measureConf=Object.assign(this.measureConf,this.measure);
		},
		handleSubmit() {
			Util.closeWindow(this, "ok",this.measureConf);
		},
		cancel() {
			Util.closeWindow(this, "cancel");
		},
	},
	watch: {}
}
</script>

<style scoped>
</style>
